<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const strCookie =
        'user_locale=zh-CN; oschina_new_user=false; remote_way=http; sensorsdata2015jssdkchannel=%7B%22prop%22%3A%7B%22_sa_channel_landing_url%22%3A%22%22%7D%7D; Serve_State=true; Hm_lvt_a1170d3ff94c236dacd36a05af8385ea=1668342821; project_pr_sort=closed_at+desc; visit-gitee--2023-05-25=1; visit-gitee--2023-05-29=1; Hm_lvt_24f17767262929947cc3631f99bfd274=1685499952,1685604801,1685705410,1685929972';

      function getCookie(cookieName) {
        // split 是字符串转数组，用;分隔字符串
        const cookieList = strCookie.split(';');

        for (let i = 0; i < cookieList.length; i++) {
          const arr = cookieList[i].split('=');
          // trim() 是字符串的方法，去除字符串的首位空格
          if (cookieName === arr[0].trim()) {
            return arr[1];
          }
        }
        // 最后这个return就是，如果传递的参数都没有找到对应的key，就返回一个空字符串
        return '';
      }

      getCookie('oschina_new_user'); // 会返回 上面的false字符串
    </script>
  </body>
</html>